//k1 edit 21.12.09

if(isNil("A3E_MortarMarkerNumber")) then {
	A3E_MortarMarkerNumber = 0;
} else {
	A3E_MortarMarkerNumber = A3E_MortarMarkerNumber +1;
};
_number = A3E_MortarMarkerNumber;
_position = [_this,0] call bis_fnc_param;

private["_obj","_pos","_dir","_gunner"];

_pos = _position vectoradd [-2.25,-8.80005,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 180;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [-4.25,-2.80005,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 270;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [-4.25,1.19995,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 270;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [3.75,3.19995,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 90;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [3.75,0.949951,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 90;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [1.75,-8.80005,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 180;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [3.75,-2.80005,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 90;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [-4.25,-6.80005,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 270;
_obj setdir _dir;
_obj setPosATL _pos;
_pos = _position vectoradd [3.75,-6.55005,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 90;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [1.75,5.19995,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 0;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [-2.25,7.44995,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 0;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [1.75,7.44995,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 0;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [-4.25,5.19995,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 270;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;
_pos = _position vectoradd [0,5.19995,0.498561];
_obj = "Land_Mil_WallBig_4m_F" createvehicle _pos;
_dir = 0;
_obj setdir _dir;
_obj setPosATL _pos;
_obj allowDamage false;

_pos = _position vectoradd [0.25,-5.55005,-0.00143862];
_obj1 = "Land_Cargo_Patrol_V1_F" createvehicle _pos;
_dir = 0;
_obj1 setdir _dir;
_obj1 setPosATL _pos;

// Statics
_gun = selectRandom (a3e_arr_Escape_SWC_MG_H + a3e_arr_Escape_SWC_GM_H);
_static = createVehicle [_gun, [0,0,0], [], 0, "NONE"];
_static attachTo [_obj1,[1.2,-1,1.1]];
detach _static;
_static setdir (getdir _obj1 -180);
Escape_allStatics pushback _static;
Escape_all_assets pushback _static;
_static setVariable ["Escape_assets_control", true, true];

_pos = _position vectoradd [-0.25,-6.24829,6.70183];
_obj = createVehicle [a3e_arr_MortarSite select(floor(random(count(a3e_arr_MortarSite)))), [0,0,999], [], 0, "NONE"]; //
_obj setDir 180;
_obj setPosATL _pos;
_gunner = [_obj,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner; 
a3e_var_artillery_units pushBack _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];

_StaticWeapons = a3e_arr_Escape_SWC_MG + a3e_arr_Escape_SWC_MG_H + a3e_arr_Escape_SWC_MG_A;
_gun = selectRandom _StaticWeapons;
_pos = _position vectoradd [-1.5,-7.05005,0];
_static = createVehicle [_gun, _pos, [], 0, "NONE"]; //"CAN_COLLIDE"
_static setDir 0;
_static setPosATL _pos;
Escape_allStatics pushback _static;
Escape_all_assets pushback _static;
_static setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _StaticWeapons;
_pos = _position vectoradd  [2.03369,3.64087,0];
_static = createVehicle [_gun, [0,0,999], [], 0, "NONE"];
_static setDir 270;
_static setPosATL _pos;
Escape_allStatics pushback _static;
Escape_all_assets pushback _static;
_static setVariable ["Escape_assets_control", true, true];


    // Special Weapon Box
    _weapons = [];
    _weaponMagazines = [];
    for "_i" from 0 to (count a3e_arr_AmmoDepotSpecialWeapons - 1) do {
        private ["_handGunItem", "_weaponClassName", "_probabilityOfPrecence", "_minCount", "_maxCount", "_magazines", "_magazinesPerWeapon"];
        
        _handGunItem = a3e_arr_AmmoDepotSpecialWeapons select _i;
        
        _weaponClassName = _handGunItem select 0;
        _probabilityOfPrecence = _handGunItem select 1;
        _minCount = _handGunItem select 2;
        _maxCount = _handGunItem select 3;
        _magazines = _handGunItem select 4;
        _magazinesPerWeapon = _handGunItem select 5;
        
        if (random 100 <= _probabilityOfPrecence) then {
            _weaponCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons pushBack [_weaponClassName, _weaponCount];
            
            for "_j" from 0 to (count _magazines) - 1 do {
                _weaponMagazines pushBack [_magazines select _j, _weaponCount * _magazinesPerWeapon];
            };
        };
    };
    if (count _weapons > 0 || {count _weaponMagazines > 0}) then {
		_pos = _position vectorAdd [2.35059,-1.43286,-0.0024395];
		_box = "CargoNet_01_box_F" createvehicle _pos;
		_box setDir 358;
		_box setPosATL _pos;
		_box allowDamage false;
		
        clearWeaponCargoGlobal _box;
        clearMagazineCargoGlobal _box;
        clearItemCargoGlobal _box;
		clearBackpackCargoGlobal _box;
		
		if (Param_NoNightvision == 0) then {_num = round random 5; if(_num > 0)then{_box addItemCargoGlobal ["NVGoggles",_num]}}; //
        
        {_box addWeaponCargoGlobal _x} foreach _weapons;
        { _box addMagazineCargoGlobal _x} foreach _weaponMagazines;
    };

Escape_campType_arr pushback [_position,"迫击炮点","k1"];
publicVariable "Escape_campType_arr";

["A3E_MortarSiteMapMarker" + str _number,_position,"o_mortar"] call A3E_fnc_createLocationMarker;

_marker = createMarkerLocal ["A3E_MortarSitePatrolMarker" + str _number, _position];
_marker setMarkerShapeLocal "ELLIPSE";
_marker setMarkerAlpha 0;
_marker setMarkerSizeLocal [50, 50];